home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / dev / c / stormamiga_lib.lha / SAL-StormC-V45_00d / Include / fcntl.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-12-22  |  3.9 KB  |  112 lines

  1. #ifndef FCNTL_H
  2. #define FCNTL_H
  3.  
  4. /*
  5. **          $VER: fcntl.h 1.4 (15.12.00)
  6. **             Includes Release 45.00
  7. **                 StormC Version
  8. **
  9. **    Copyright © 1996/2000 by CyberdyneSystems
  10. **
  11. **            written by Matthias Henze
  12. **               All Rights Reserved
  13. */
  14.  
  15. #ifndef STORMAMIGA_H
  16.   #include <stormamiga.h>
  17. #endif
  18. #ifndef SYS_TYPES_H
  19.   #include <sys/types.h>
  20. #endif
  21.  
  22. #ifdef __cplusplus
  23.   extern "C" {
  24. #endif
  25.  
  26. /*
  27.  * File status flags: these are used by open.
  28.  * They are also used (indirectly) in the kernel file structure f_flags,
  29.  * which is a superset of the open/fcntl flags.  Open flags and f_flags
  30.  * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
  31.  * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
  32.  */
  33. /* open-only flags */
  34. #define O_RDONLY        0x0000          /* open for reading only */
  35. #define O_WRONLY        0x0001          /* open for writing only */
  36. #define O_RDWR          0x0002          /* open for reading and writing */
  37. #define O_ACCMODE       0x0003          /* mask for above modes */
  38.  
  39. #define FREAD           0x0001
  40. #define FWRITE          0x0002
  41. #define O_NONBLOCK      0x0004          /* no delay */
  42. #define O_APPEND        0x0100          /* set append mode */
  43.  
  44. #ifndef _POSIX_SOURCE
  45.   #define O_SHLOCK        0x0           /* open with shared file lock */
  46.   #define O_EXLOCK        0x0           /* open with exclusive file lock */
  47.   #define O_ASYNC         0x0040        /* signal pgrp when data ready */
  48.   #define O_FSYNC         0x2000        /* synchronous writes */
  49.   #define O_CASE          0x1000        /* open file using a case-sensitive filename */
  50. #endif
  51.  
  52. #define O_CREAT         0x0200          /* create if nonexistant */
  53. #define O_TRUNC         0x0400          /* truncate to zero length */
  54. #define O_EXCL          0x0800          /* error if already exists */
  55. #define FEXTOPEN        0x0010          /* don't close with DOS Close command */
  56. #define FUNLINK         0x0080          /* unlink file when closed */
  57. #define FMARK           0x0             /* mark during gc() */
  58. #define FDEFER          0x0             /* defer for next gc pass */
  59. #define FHASLOCK        0x0             /* descriptor holds advisory lock */
  60.  
  61. /* defined by POSIX 1003.1; BSD default, so no bit required */
  62. #define O_NOCTTY        0               /* don't assign controlling terminal */
  63.  
  64. /*
  65.  * The O_* flags used to have only F* names, which were used in the kernel
  66.  * and by fcntl.  We retain the F* names for the kernel f_flags field
  67.  * and for backward compatibility for fcntl.
  68.  */
  69. #ifndef _POSIX_SOURCE
  70.   #define FAPPEND         O_APPEND        /* kernel/compat */
  71.   #define FASYNC          O_ASYNC         /* kernel/compat */
  72.   #define FFSYNC          O_FSYNC         /* kernel */
  73.   #define FNONBLOCK       O_NONBLOCK      /* kernel */
  74.   #define FNDELAY         O_NONBLOCK      /* compat */
  75.   #define FNBIO           O_NONBLOCK      /* compat */
  76.   #define O_NDELAY        O_NONBLOCK      /* compat */
  77. #endif
  78.  
  79. #define FOPEN           (-1)
  80. /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
  81. #define FFLAGS(oflags)  ((oflags) + 1)
  82. #define OFLAGS(fflags)  ((fflags) - 1)
  83.  
  84. /* bits to save after open */
  85. #define FMASK           (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
  86. /* bits settable by fcntl(F_SETFL, ...) */
  87. #define FCNTLFLAGS      (FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
  88.  
  89.  
  90. /* file descriptor flags (F_GETFD, F_SETFD) */
  91. #define FD_CLOEXEC      1               /* close-on-exec flag */
  92.  
  93. int     creat (cchar *, mode_t);
  94. int     open  (cchar *, int, ...);
  95.  
  96. #ifdef __cplusplus
  97.   }
  98. #endif
  99.  
  100. #ifdef STORMAMIGA_UNIXPATH
  101.   __inline int creat_u (cchar *path, mode_t mode)
  102.   { return creat       (path, mode);}
  103.  
  104.   __inline int open_u  (cchar *path, int flags)
  105.   { return open        (path, flags); }
  106.  
  107.   #define creat(path, mode) creat_u(UnixToAmigaPath(path), mode)
  108.   #define open(path, flags) open_u(UnixToAmigaPath(path), flags)
  109. #endif
  110.  
  111. #endif /* FCNTL_H */
  112.